<template>
	<view class="box">
		<u-navbar title="我的钱包" :fixed="true" :placeholder="true" :safeAreaInsetTop="true" :autoBack="false"
			leftIconColor="#fff" titleStyle="color:#fff" bgColor="#211E38" rightText="规则" @rightClick="right"
			@leftClick="leftClick"></u-navbar>
		<view class="wallet_detail">
			<view class="wallet_detail_title" @click="shuoming=true,sel=1">
				可用福合通宝  <image  src="../../static/image/wenhao.png" mode=""></image>
			</view>
			<view class="wallet_detail_num1"
				:style="user.balance.length > 8 ? 'font-size: 52rpx;' : 'font-size: 62rpx;'">
				{{user.balance}}
			</view>
			<view class="btn_wrap">
				<view class="btn_item" @click="gofhdetail">
					详情
				</view>
			<!-- 	<view class="btn_item" @click="gowithdraw">
					转账
				</view> -->
			</view>
<!-- 			<view class="wallet_detail_bottom">
				<view class="wallet_detail_bottom_right" @click="gowithdrawlist">
					<text>明细</text>
					<uni-icons type="right" color="#A7A4AD"></uni-icons>
				</view>
			</view> -->
		</view>
		<view class="wallet_detail">
			<view class="wallet_detail_title" >
				FUL  
			</view>
			<view class="btn_wrap" style="top: 100rpx;">
				<view class="btn_item" @click="gofulsell">
					挂售
				</view>
			<!-- 	<view class="btn_item" @click="gowithdraw">
					转账
				</view> -->

			</view>
			<view class="wallet_detail_num"
				:style="user.balance_ful.length > 8 ? 'font-size: 52rpx;' : 'font-size: 62rpx;'">
				{{user.balance_ful}}
			</view>

			<view class="wallet_detail_bottom">
				<view class="wallet_detail_bottom_right" @click="gofullist">
					<text>明细</text>
					<uni-icons type="right" color="#A7A4AD"></uni-icons>
				</view>
			</view>
		</view>
		<view class="wallet_detail">
			<view class="wallet_detail_title"  @click="shuoming=true,sel=3">
				FH原石  <image  src="../../static/image/wenhao.png" mode=""></image>
			</view>
			<view class="wallet_detail_num"
				:style="user.balance_ful.length > 8 ? 'font-size: 52rpx;' : 'font-size: 62rpx;'">
				{{user.balance_hf||"0.0"}}
			</view>

			<view class="wallet_detail_bottom">
				<view class="wallet_detail_bottom_right" @click="gofhlist">
					<text>明细</text>
					<uni-icons type="right" color="#A7A4AD"></uni-icons>
				</view>
			</view>
		</view>

		<view class="main" >
			<view class="main_tit">
				三方钱包
			</view>
			<view class="main_item">
				<view class="main_item_tit">
					<image src="../../static/image/wallet_bg.png" mode=""></image>
					<text>新生钱包</text>
				</view>
				<view class="main_item_center">
					<view class="main_item_price">
						{{xs.balAmount||"0.00"}}<text>(元)</text>
					</view>
					<view class="main_item_btn" v-if="!isxs" @click="goopenwallet(1)">
						开通钱包
					</view>
					<view class="main_item_btn" v-if="isxs" @click="gowalletdetail(1)">
						钱包管理
					</view>
				</view>
				<view class="main_tip">
					可提现余额
				</view>
			</view>
			<view class="main_item" >
				<view class="main_item_tit">
					<image src="../../static/image/wallet_bg2.png" mode=""></image>
					<text>杉德钱包</text>
				</view>
				<view class="main_item_center">
					<view class="main_item_price">
						{{sd.balAmount||"0.00"}}<text>(元)</text>
					</view>
					<view class="main_item_btn2"   v-if="!issd" @click="goopenwallet(2)">
						开通钱包
					</view>
					<view class="main_item_btn" v-if="issd" @click="gosd">
						钱包管理
					</view>
				</view>
				<view class="main_tip">
					可提现余额
				</view>
			</view>
		</view>
		<u-popup :show="ruleflag" :round="10" mode="bottom" @close="close" @open="open" :closeable="true">
			<view class="rule_content">
				<view class="rule_tit">
					规则
				</view>
				<view class="rule_text">
					<rich-text class="quanyi_s"  :nodes="text"></rich-text>
				</view>
			</view>
		</u-popup>
		<u-popup :show="shuoming" :round="10" mode="center" bgColor="transparent" @close="shuoming=false" :closeable="true">
			<view class="shuo_content">
				<view class="shuo_tit">
					说明
				</view>
				<view class="shuo_txt" v-if="sel==3">
					1.FH原石可通过特定活动获得，可于福合宇宙·多彩王朝App内消费使用。
					<br />
					2.1FH原石相当于1￥
					<br />
					3.FH原石不支持转账提现
				</view>
				<view class="shuo_txt" v-if="sel==1">
				1.福合通宝是福合宇宙·多彩王朝App内的流通凭证
				通过充值、任务、寄售等途径获得
				可于App内消费使用
					<br />
					2.福合通宝相当于1￥
		
				</view>
			</view>
		</u-popup>
		<u-popup :show="selpayflag" bgColor="transparent" mode="center" @close="selpayflag=false" @open="open"
			:closeable="true">
			<view class="selpay">
				<view class="selpay_tit">
					选择充值钱包
				</view>
				<view class="selitem" v-if="isxs" @click="gotopup">
					新生钱包
				</view>
				<view class="selitem" v-if="issd">
					杉德钱包
				</view>
			</view>
		</u-popup>
				<u-popup :show="tipShow2" mode="center" @close="tipShow2 = false" closeable bgColor="transparent">
					<view class="prompt flex_ZC">
						<text class="f36">提示</text>
						<text class="prompt_tit">您还未实名，请先实名</text>
		
						<view class="prompt_ntm" @click="goreal">
							<text>点击去实名</text>
						</view>
						<view class="empty"></view>
					</view>
				</u-popup>
	</view>

</template>

<script>
	import {
		getuserinfo
	} from "../../api/index.js"
	import {
		balanceList,
		walletRules,
		myAccount
	} from "../../api/wallet.js"
	export default {
		data() {
			return {
				ruleflag: false,
				fuhelist: {},
				shuoming:false,
				sel:1,
				user: {
					balance: "0.00",
					balance_ful: "0.00",
					balance_hf: "0.00"
				},
				text: "",
				selpayflag: false,
				isopen: false, //是否开通钱包
				isxs: false,
				xs: {
					balAmount: "0.00"
				},
				sd: {
					balAmount: "0.00"
				},
				issd: false,
				tipShow2:false,
				sdurl:""

			}
		},
		// onLoad() {
		// 	this.getuser()
		// 	this.getrule()
		// 	this.getmyAccount()
		// },
		onShow() {
			this.getuser()
			this.getrule()
			this.getmyAccount()
			this.selpayflag = false
			this.tipShow2=false
		},
		methods: {
			gofulsell(){
				uni.navigateTo({
					url:"/pagesMy/mywallet/fulsell"
				})
			},
			gofhdetail(){
				uni.navigateTo({
					url:"/pagesMy/mywallet/fhdetail"
				})
			},
			leftClick() {
				//获取页面栈的长度
				const canNavBack = getCurrentPages()
				console.log(canNavBack.length);
				// 判断是否刷新了浏览器，刷新了浏览器，页面栈只有当前一个
				if (canNavBack.length > 1) {
					uni.navigateBack({
						delta: 1
					})
				} else {
					uni.switchTab({
						url: '/pages/index/index'
					})
				}
			},
			gosd(){
				// #ifdef APP
						uni.navigateTo({
							url:"/pagesMy/mywallet/webviewtwo"
						})
				// #endif
				// #ifdef H5
					window.location.href=this.sdurl
				// #endif
				
			},
			totopup() {
				// uni.navigateTo({
				// 	url:"/pagesMy/mywallet/proceeds"
				// })
				if (this.isopen) {
					this.gotopup()
				} else {
					uni.$u.toast("请开通钱包")
				}
			},
			goreal(){
				uni.navigateTo({
					url:"/pagesMy/setting/realNameAuthentication"
				})
			},
			getmyAccount() {
				myAccount().then(res => {
					this.isopen = res.data.switch
					this.isxs = res.data.xs_is_switch
					this.xs = res.data.xs
					this.sd = res.data.sd
					this.issd = res.data.sd_is_switch
					if(this.issd==1){
						this.sdurl=res.data.sd.url
					}
					console.log(this.isopen, "000")
					console.log(res, "账户")
				})
			},
			getuser() {
				getuserinfo().then(res => {
					this.user = res.data
					console.log(this.user.balance.length, "//")
				})
				console.log()
			},
			gowithdrawlist() {
				uni.navigateTo({
					url: "/pagesMy/mywallet/withdrawlist"
				})
			},
			getfuhelist() {
				balanceList().then(res => {

				})
			},
			getrule() {
				walletRules().then(res => {
					this.text = res.data.wallet_rules
					console.log(res)
				})
			},
			right() {
				this.ruleflag = true
			},
			open() {
				// console.log('open');
			},
			close() {
				this.ruleflag = false
				// console.log('close');
			},
			goopenwallet(type) {
				if(this.user.is_real==0){
					this.tipShow2=true
				}else{
					uni.navigateTo({
						url: `/pagesMy/mywallet/openwallet?type=${type}`
					})
					uni.setStorageSync('bankType',type)
				}
				
			},
	
			gofullist() {
				uni.navigateTo({
					url: "/pagesMy/mywallet/fullist"
				})
			},
			gofhlist() {
				uni.navigateTo({
					url: "/pagesMy/mywallet/fhlist"
				})
			},
			gotopup() {
				uni.navigateTo({
					url: "/pagesMy/mywallet/topupfh"
				})
			},
			gowithdraw() {
					// uni.$u.toast("敬请期待，功能暂未开放")
				if (this.isopen) {
					uni.navigateTo({
						url: "/pagesMy/mywallet/withdrawwallet"
					})
				} else {
					uni.$u.toast("请开通钱包")
				}

			},
			gowalletdetail(type) {
				uni.navigateTo({
					url: "/pagesMy/mywallet/walletdetail"
				})
				uni.setStorageSync('bankType',type)
			}
		}
	}
</script>
<style>
	page {
		background: #211E38;
	}
</style>

<style lang="scss" scoped>
	@font-face {
		font-family: 'iconfont';
		src: url("~@/iconfont/almm.ttf");
	}

	.box {
		width: 750rpx;
		height: 1624rpx;
		// background-color: #211E38;
		position: relative;
	}

	.rtext {
		// background-color: none !important;
	}

	/deep/ .u-navbar__content__right__text {
		color: #FFFFFF;
	}

	.wallet_detail {
		width: 690rpx;
		height: 224rpx;
		background-color: #423E5C;
		border-radius: 26rpx;
		margin: 0 auto;
		position: relative;
		margin-top: 40rpx;
		background-image: url("../../static/image/walletbg.png");
		background-size: 690rpx 224rpx;

		.wallet_detail_title {
			display: flex;
			width: 300rpx;
			// justify-content: space-between;
			font-size: 36rpx;
			color: #FFFFFF;
			line-height: 52rpx;
			padding-top: 32rpx;
			margin-left: 32rpx;
			align-items: center;
			position: relative;
			// z-index: 50;
			>image{
				width: 25rpx;
				height: 25rpx;
				margin-left: 15rpx;
			}
			.wallet_text {
				margin-right: 20rpx;
				color: #D7D6E1;
				font-size: 34rpx !important;
			}
		}

		.wallet_detail_num {
			font-weight: 700;
			// font-size: 62rpx;
			color: #FFFFFF;
			margin-top: 32rpx;
			margin-left: 32rpx;
			width: 300rpx;

		}

		.wallet_detail_num1 {
			width: 300rpx;
			position: absolute;
			top: 116rpx;
			left: 16rpx;
			font-weight: 700;
			// font-size: 62rpx;
			color: #FFFFFF;
		}

		.line {
			width: 626rpx;
			margin: 0 auto;
			margin-top: 50rpx;
			border-bottom: 2rpx dashed rgba(255, 255, 255, 0.2);
		}

		.btn_wrap {
			width: 300rpx;
			position: absolute;
			top: 66rpx;
			right:-100rpx;
			display: flex;
			justify-content: space-between;

			.btn_item {
				width: 140rpx;
				height: 60rpx;
				background: linear-gradient(274deg, #0014FF 0%, #8020EF 50%, #FF2CDF 100%);
				box-shadow: 0rpx 8rpx 12rpx 2rpx rgba(59, 8, 71, 0.3);
				border-radius: 536rpx 536rpx 536rpx 536rpx;
				font-weight: 500;
				font-size: 28rpx;
				color: #FFFFFF;
				text-align: center;
				line-height: 60rpx;
			}
		}

		.wallet_detail_bottom {
			width: 126rpx;
			margin: 0 auto;
			display: flex;
			// height: 100rpx;
			align-items: center;
			justify-content: flex-end;
			position: absolute;
			top: 32rpx;
			right: 34rpx;

			>text {
				font-weight: 500;
				font-size: 36rpx;
				color: #FFFFFF;
			}

			.wallet_detail_bottom_right {
				color: #D7D6E1;
				font-size: 28rpx !important;
			}


		}
	}

	.main {
		width: 750rpx;
		height: 850rpx;
		background: #3C2F65;
		border-radius: 50rpx 50rpx 0rpx 0rpx;
		margin-top: 60rpx;
		padding-bottom: 50rpx;
		// position: absolute;
		// bottom: 0rpx;

		.main_tit {
			width: 750rpx;
			text-align: center;
			padding-top: 36rpx;
			font-weight: 700;
			font-size: 36rpx;
			color: #FFFFFF;
			font-family: iconfont;
		}

		.main_item {
			width: 690rpx;
			height: 306rpx;
			background: #342857;
			border-radius: 24rpx 24rpx 24rpx 24rpx;
			border: 4rpx solid #48397A;
			margin: 0 auto;
			margin-top: 62rpx;
			position: relative;

			.main_item_tit {
				width: 232rpx;
				height: 46rpx;
				position: absolute;
				left: 244rpx;
				top: -23rpx;

				>image {
					width: 202rpx;
					height: 46rpx;
					display: block;
				}

				>text {
					position: absolute;
					left: 45%;
					top: 50%;
					transform: translate(-50%, -50%);
					font-weight: 400;
					font-size: 28rpx;
					color: #FFFFFF;
				}
			}

			.main_item_center {
				margin-top: 96rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.main_item_price {
					width: 460rpx;
					font-weight: 400;
					font-size: 72rpx;
					color: #FFFFFF;
					margin-left: 32rpx;

					>text {
						font-size: 28rpx;
						color: #FFFFFF;
						margin-left: 10rpx;
					}
				}

				.main_item_btn {
					margin-right: 32rpx;
					width: 144rpx;
					height: 52rpx;
					background: linear-gradient(274deg, #E862E6 9%, #E529E2 97%);
					border-radius: 8rpx 8rpx 8rpx 8rpx;
					font-weight: 400;
					font-size: 28rpx;
					color: #FFFFFF;
					text-align: center;
					line-height: 52rpx;
				}

				.main_item_btn2 {
					margin-right: 32rpx;
					width: 144rpx;
					height: 52rpx;
					background: linear-gradient(274deg, #9445F0 9%, #8020EF 96%);
					border-radius: 8rpx 8rpx 8rpx 8rpx;
					font-weight: 400;
					font-size: 28rpx;
					color: #FFFFFF;
					text-align: center;
					line-height: 52rpx;
				}
			}

			.main_tip {
				font-weight: 400;
				font-size: 28rpx;
				color: #A6A5AF;
				margin-top: 16rpx;
				margin-left: 32rpx;
			}
		}
	}

	.rule_content {
		padding-top: 60rpx;
		width: 750rpx;
		height: 500rpx;
		background-color: #3C2F65;

		.rule_tit {
			font-weight: 500;
			font-size: 36rpx;
			color: #FFFFFF;
			text-align: center;
		}

		.rule_text {
			width: 650rpx;
			margin: 0 auto;
			overflow: auto;
		}


	}

	.quanyi_s {
		width: 100%;
		overflow: hidden;
		color: #ffffff;
		font-size: 28rpx;
		padding: 0 30rpx;
	}

	.selpay {
		width: 602rpx;
		max-height: 464rpx;
		min-height: 300rpx;
		background: #2A2753;
		padding-bottom: 50rpx;
		// border-radius: 22rpx 22rpx 22rpx 22rpx;
		border-radius: 20rpx;

		.selpay_tit {
			font-weight: 500;
			font-size: 36rpx;
			color: #FFFFFF;
			width: 602rpx;
			margin: 0 auto;
			text-align: center;
			margin-top: 50rpx;
		}

		.selitem {
			margin: 0 auto;
			margin-top: 50rpx;
			width: 522rpx;
			height: 80rpx;
			background: linear-gradient(274deg, #0014FF 0%, #8020EF 50%, #FF2CDF 100%);
			border-radius: 410rpx 410rpx 410rpx 410rpx;
			text-align: center;
			line-height: 80rpx;
			font-weight: 400;
			font-size: 34rpx;
			color: #FFFFFF;
		}
	}
	.prompt {
		width: 600rpx;
		min-height: 400rpx;
		background: #2A2753;
		margin: 0 auto;
		border-radius: 20rpx;
		color: #ffffff;
		padding-top: 30rpx;
	}
	
	.prompt>text {
		margin-top: 40rpx;
	}
	
	.prompt_tit {
		margin: 0 30rpx;
		font-size: 28rpx;
		color: #A6A5AF;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
	}
	
	.prompt_ntm {
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 30rpx;
		width: 414rpx;
		height: 72rpx;
		line-height: 72rpx;
		background: linear-gradient(274deg, #0014FF 0%, #8020EF 50%, #FF2CDF 100%);
		border-radius: 28rpx;
		margin-top: 80rpx;
	}
	.shuo_content{
		width: 670rpx;
		margin: 0 auto;
		height: 400rpx;
		background-color: #3C2F65;
		border-radius: 20rpx;
		.shuo_tit{
			font-weight: 500;
			font-size: 36rpx;
			color: #FFFFFF;
			text-align: center;
			margin-top: 40rpx;
		}
		.shuo_txt{
			width: 600rpx;
			margin: 0 auto;
			margin-top: 20rpx;
			color: #FFFFFF;
			font-size: 28rpx;
		}
	}
	
	
</style>